package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.OtherBlocketRecord;
import com.ruoyi.system.domain.OtherHostRecord;
import com.ruoyi.system.domain.OtherMicSlotClaim;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@DataSource(value = DataSourceType.SLAVE)
public interface OtherHostRecordMapper extends BaseMapper<OtherHostRecord> {
    @Select("select wxid ,displayName, COUNT(*)  as operationcount from HostRecord where roomID=  #{roomId} AND deleteFlag = 0 and DATE(roundStartTime) BETWEEN #{startDate} AND #{endDate}  AND TIME(roundStartTime) BETWEEN #{startTime} AND #{endTime} group by wxid,displayName")
    public List<HashMap> getHostRecord(@Param("roomId") String roomID,@Param("startDate") String startDate, @Param("endDate")String endDate, @Param("startTime")String startTime, @Param("endTime")String endTime);


    @Select("select * from HostRecord where roomID=  #{roomId} and wxid = #{wxid} AND deleteFlag = 0  and DATE(roundStartTime) BETWEEN #{startDate} AND #{endDate}  AND TIME(roundStartTime) BETWEEN #{startTime} AND #{endTime} ")
    public List<OtherHostRecord> getHostRecordByMember(@Param("roomId") String roomID,@Param("wxid") String wxid, @Param("startDate") String startDate, @Param("endDate")String endDate, @Param("startTime")String startTime, @Param("endTime")String endTime);


    @Select("select roomID,  wxid, MAX(roundStartTime) as lasttime from HostRecord ${ew.customSqlSegment}")
    public List<Map<String, Object>> getMemberLastRecord(@Param(Constants.WRAPPER) QueryWrapper<OtherHostRecord> queryWrapper);

}
